package org.goodprinciples.oracolo.model;

import java.util.Objects;
import org.goodprinciples.commons.bean.CodeDescriptionBean;

/**
 *
 * @author Francesco Conte
 */
public class Domain extends OracoloBean<Domain> {
    
    private Long id = null;
    private String name = null;
    private DomainType type = null;
    private Domain parent = null;
    
    public Domain() {}

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Domain getParent() {
        return parent;
    }

    public void setParent(Domain parent) {
        this.parent = parent;
    }

    public DomainType getType() {
        return type;
    }

    public void setType(DomainType type) {
        this.type = type;
    }

    public boolean equals(java.lang.Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final Domain other = (Domain) obj;
        if (!Objects.equals(this.id, other.id)) {
            return false;
        }
        return true;
    }

    public int hashCode() {
        int hash = 3;
        hash = 83 * hash + Objects.hashCode(this.id);
        return hash;
    }

    public String toString() {
        return "Domain{" + "id=" + id + ", name=" + name + ", type=" + type + ", parent=" + parent + '}';
    }
    
    public static enum DomainType implements CodeDescriptionBean {
        
        CLASSIC("C", "Classic domain"),
        QUERY("Q", "Query based domain"),
        REGEXP("R", "Regexp based domain"),
        ;
        
        private DomainType(String code, String description) {
            this.code = code;
            this.description = description;
        }
        
        private String code = null;
        private String description = null;

        @Override
        public String getCode() {
            throw new UnsupportedOperationException("Not supported yet.");
        }

        @Override
        public String getDescription() {
            throw new UnsupportedOperationException("Not supported yet.");
        }

        public String toString() {
            return "DomainType{" + "code=" + code + ", description=" + description + '}';
        }
        
    }
    
}
